package com.euro.video.phone.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.euro.video.phone.utils.EvpEnum;

@Entity
@Table(name="article", schema="evp_db")
@NamedQueries({
	@NamedQuery(name="lireArticleParNom", query="select art from Article art where art.nom = :nom"),
	@NamedQuery(name="listArticlesParType", query="select art from Article art where art.type = :type"),
	@NamedQuery(name="listArticlesEnPromo", query="select art from Article art where art.enPromo=true"),
	@NamedQuery(name="imageArticle", query="select art.image from Article art where art.nom = :nom"),
	@NamedQuery(name="articlesRecents", query="select art from Article art order by art.creation desc")
})

public class Article implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(insertable=true, updatable=false)
	private long id;
	@Column(nullable=false, unique=true, length=32)
	private String nom;
	@Column(nullable=false, columnDefinition="text")
	private String resume;
	@Column(nullable=true, columnDefinition="longtext")
	private String description;
	@Column(nullable=false)
	private double prix;
	@Column(nullable=false)
	private boolean enPromo;
	@Column(nullable=true)
	private double prixPromo;
	@Column(nullable=false)
	private boolean aLaUne;
	@Column(nullable=false)
	private EvpEnum type;
	@Column(nullable=true, columnDefinition = "mediumblob")
	private byte[] image;
	@Column(nullable=false)
	private Date creation;
	
	public Article() {
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getResume() {
		return resume;
	}

	public void setResume(String resume) {
		this.resume = resume;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public double getPrix() {
		return prix;
	}

	public void setPrix(double prix) {
		this.prix = prix;
	}

	public boolean isEnPromo() {
		return enPromo;
	}

	public void setEnPromo(boolean enPromo) {
		this.enPromo = enPromo;
	}

	public double getPrixPromo() {
		return prixPromo;
	}

	public void setPrixPromo(double prixPromo) {
		this.prixPromo = prixPromo;
	}

	public boolean isaLaUne() {
		return aLaUne;
	}

	public void setaLaUne(boolean aLaUne) {
		this.aLaUne = aLaUne;
	}

	public byte[] getImage() {
		return image;
	}

	public EvpEnum getType() {
		return type;
	}

	public void setType(EvpEnum type) {
		this.type = type;
	}

	public void setImage(byte[] image) {
		this.image = image;
	}

	public Date getCreation() {
		return creation;
	}

	public void setCreation(Date creation) {
		this.creation = creation;
	}
}
